package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.mapper.LogMapper;
import com.itheima.pojo.Log;
import com.itheima.pojo.PageResult;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;

    @Override
    public PageResult findLog(Integer page, Integer pageSize) {

        // 创建分页对象
        Page<Log> pageParam = new Page<>(page, pageSize);

        // MyBatis-Plus 自动分页
        Page<Log> pageResult = logMapper.findLog(pageParam);

        long total = pageResult.getTotal();
        List<Log> rows = pageResult.getRecords();

        return new PageResult(total, rows);
    }
}